<script type="text/javascript">
  $().ready(function() {
    $("#new_item_form").validate({
      rules: { "item[kanji]": {
          required: true,
          maxlength: 16
        },"item[kana]": {
          required: true,
          maxlength: 16
        },"item[translation]": {
          required: true,
          maxlength :20
        },
        "item[pos]":{
          required: true
        }
      },
      messages:{
        "item[kanji]": {
          required: "请输入单词的汉字.",
          maxlength: "最多只能输入16个字符."
        },"item[kana]": {
          required: "请输入单词的假名.",
          maxlength: "最多只能输入个字符."
        },"item[translation]": {
          required: "请输入单词译文.",
          maxlength: "最多只能输入20个字符."
        },"item[pos]":{
          required: "请选择单词的词性."
        }
      },
      errorPlacement: function(error,element){
        error.appendTo(element.next());
      }
    })
  });
</script>
<div class="sub_pannel">
  <div class="content">
    <div class="title">
      <span class="text">
        添加单词
      </span>
    </div>
    <div class="item_pannel">
      <%form_for  @item, new_item_path,:html=>{:id=>"new_item_form"}  do |f|%>
        <p>
          <%=label_tag "日文汉字" ,nil,:class=>"label" %>
          <%=f.text_field :kanji , :class=>'text'%>
          <span></span>
        </p>
        <p>
          <%=label_tag "日文假名" ,nil,:class=>"label" %>
          <%=f.text_field :kana , :class=>'text'%>
          <span></span>
        </p>
        <p>
          <%=label_tag "中文翻译" ,nil,:class=>"label" %>
          <%=f.text_field :translation , :class=>'text'%>
          <span></span>
        </p>
        <p>
          <%=label_tag "词性" ,nil,:class=>"label" %>
          <%= select :item ,:pos ,@poses.collect{ |p|[p.name,p.name]},{:include_blank=>true,:selected=>0}%><span></span>
        </p>
        <div class="p_submit">
          <%= hidden_field_tag "item[course_id]",@course_id%>
          <%=f.submit "添加" ,:class=>"submit"%>
        </div>
      <%end%>
    </div>
  </div>
</div>